package com.opgea.crm.web.form;

import java.util.ArrayList;
import java.util.List;

import com.opgea.crm.common.util.DateUtil;
import com.opgea.crm.domain.entities.Lead;
import com.opgea.crm.domain.entities.Leademails;
import com.opgea.crm.domain.entities.Leadphones;
import com.opgea.crm.domain.entities.ProjectDetails;

public class ProjectReportForm {
	
	private Long projectReportId;
	private Long leadId;
	private String projectNameReport;
	private String projectDetailsReport;
	private String actualStartDateReport;
	private String actualEndDateReport;
	private String actualBudgetReport;
	private String actualHrsReport;
	
	//for customer details
	private String customerName;
	private String companyName;
	private String mobileNumber;
	private String emailId;
	private String faxNumber;
	
	//for member details
	private String memberName;
	private String memberCompanyName;
	private String memberEmailId;
	private String memberMobileNumber;
	private String memberFaxNumber;
	
	
   //combos
	private String contactTo;
	private long contactToId;
	private String statusReport;
	private long statusId;
	private String priorityReport;
	private long priorityId;
	
	
    
	public Long getProjectReportId() {
		return projectReportId;
	}
	public void setProjectReportId(Long projectReportId) {
		this.projectReportId = projectReportId;
	}
	public Long getLeadId() {
		return leadId;
	}
	public void setLeadId(Long leadId) {
		this.leadId = leadId;
	}
	
	public String getProjectNameReport() {
		return projectNameReport;
	}
	public void setProjectNameReport(String projectNameReport) {
		this.projectNameReport = projectNameReport;
	}
	public String getProjectDetailsReport() {
		return projectDetailsReport;
	}
	public void setProjectDetailsReport(String projectDetailsReport) {
		this.projectDetailsReport = projectDetailsReport;
	}
	public String getActualStartDateReport() {
		return actualStartDateReport;
	}
	public void setActualStartDateReport(String actualStartDateReport) {
		this.actualStartDateReport = actualStartDateReport;
	}
	public String getActualEndDateReport() {
		return actualEndDateReport;
	}
	public void setActualEndDateReport(String actualEndDateReport) {
		this.actualEndDateReport = actualEndDateReport;
	}
	public String getActualBudgetReport() {
		return actualBudgetReport;
	}
	public void setActualBudgetReport(String actualBudgetReport) {
		this.actualBudgetReport = actualBudgetReport;
	}
	public String getActualHrsReport() {
		return actualHrsReport;
	}
	public void setActualHrsReport(String actualHrsReport) {
		this.actualHrsReport = actualHrsReport;
	}
	public String getStatusReport() {
		return statusReport;
	}
	public void setStatusReport(String statusReport) {
		this.statusReport = statusReport;
	}
	public String getPriorityReport() {
		return priorityReport;
	}
	public void setPriorityReport(String priorityReport) {
		this.priorityReport = priorityReport;
	}
	public String getCustomerName() {
		return customerName;
	}
	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}
	public String getCompanyName() {
		return companyName;
	}
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}
	public String getMobileNumber() {
		return mobileNumber;
	}
	public void setMobileNumber(String mobileNumber) {
		this.mobileNumber = mobileNumber;
	}
	

   public String getContactTo() {
		return contactTo;
	}
	public void setContactTo(String contactTo) {
		this.contactTo = contactTo;
	}
	public long getContactToId() {
		return contactToId;
	}
	public void setContactToId(long contactToId) {
		this.contactToId = contactToId;
	}
	
	public long getStatusId() {
		return statusId;
	}
	public void setStatusId(long statusId) {
		this.statusId = statusId;
	}
	
	public long getPriorityId() {
		return priorityId;
	}
	public void setPriorityId(long priorityId) {
		this.priorityId = priorityId;
	}
	
public String getEmailId() {
		return emailId;
	}
	public void setEmailId(String emailId) {
		this.emailId = emailId;
	}
	public String getFaxNumber() {
		return faxNumber;
	}
	public void setFaxNumber(String faxNumber) {
		this.faxNumber = faxNumber;
	}
	
	
	
    public String getMemberName() {
		return memberName;
	}
	public void setMemberName(String memberName) {
		this.memberName = memberName;
	}
	public String getMemberCompanyName() {
		return memberCompanyName;
	}
	public void setMemberCompanyName(String memberCompanyName) {
		this.memberCompanyName = memberCompanyName;
	}
	public String getMemberEmailId() {
		return memberEmailId;
	}
	public void setMemberEmailId(String memberEmailId) {
		this.memberEmailId = memberEmailId;
	}
	public String getMemberMobileNumber() {
		return memberMobileNumber;
	}
	public void setMemberMobileNumber(String memberMobileNumber) {
		this.memberMobileNumber = memberMobileNumber;
	}
	public String getMemberFaxNumber() {
		return memberFaxNumber;
	}
	public void setMemberFaxNumber(String memberFaxNumber) {
		this.memberFaxNumber = memberFaxNumber;
	}
	
	
	public ProjectReportForm(){}
	
	public ProjectReportForm(ProjectDetails projectDetails)
	{
		Lead lead= projectDetails.getCustomer();  
		List<Leadphones> phones = new ArrayList<Leadphones>(lead.getLeadphonesCollection());
		
		Leadphones phone1 = null;
		Leadphones phone2 = null;
		if(phones.size()>0){
			phone1 = phones.get(0);
			phone2 = phones.get(1);
		}
		Leademails email1 = lead.getLeademail();
		
		this.setProjectReportId(projectDetails.getId());
		this.setProjectNameReport(projectDetails.getProjectName());
		
		if(projectDetails.getStatus()!=null)
		{
			this.setStatusReport(projectDetails.getStatus().getFieldValue());
		    this.setStatusId(projectDetails.getStatus().getId());
		}
	    if(projectDetails.getCustomer()!=null)
	    this.setLeadId(projectDetails.getCustomer().getId());
	    
	    if(projectDetails.getCustomer()!=null){
	    this.setCustomerName(projectDetails.getCustomer().getFirstName());
	    this.setCompanyName(projectDetails.getCustomer().getCompany().getName());
	    }
	    if(projectDetails.getContactTo()!=null)
	    {
	    	this.setContactTo(projectDetails.getContactTo().getFirstName());
	    	this.setContactToId(projectDetails.getContactTo().getId());
	    }
	    if(projectDetails.getPriority()!=null)
	    {
	    	this.setPriorityReport(projectDetails.getPriority().getFieldValue());
	    	this.setPriorityId(projectDetails.getPriority().getId());
	    }
	    this.setActualStartDateReport(DateUtil.dateToString(projectDetails.getActualStartDate()));
	    this.setActualEndDateReport(DateUtil.dateToString(projectDetails.getActualEndDate()));
	    this.setActualBudgetReport(projectDetails.getActualBudget().toString());
	    this.setActualHrsReport(projectDetails.getActualTakenHrs().toString());
	    String details = new String(projectDetails.getProjectDetails());
	    this.setProjectDetailsReport(details);
	    
	    this.setMobileNumber(phone1.getPhoneNo());
		this.setFaxNumber(phone2.getPhoneNo());
		this.setEmailId(email1.getAddress());
		
		if(projectDetails.getContactTo() != null){
		this.setMemberName(projectDetails.getContactTo().getFirstName());
		this.setMemberCompanyName(projectDetails.getContactTo().getLead().getCompany().getName());
		}
	}
	
	
	
}
